<?php /* Smarty version Smarty3-RC3, created on 2013-10-10 13:25:19
         compiled from ".\templates\kaarigarEntry.tpl" */ ?>
<?php /*%%SmartyHeaderCode:35195256aabfd68597-50234053%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    '8b62330bfd6c48392172f93580e48e7fc31fead6' => 
    array (
      0 => '.\\templates\\kaarigarEntry.tpl',
      1 => 1320849608,
    ),
  ),
  'nocache_hash' => '35195256aabfd68597-50234053',
  'function' => 
  array (
  ),
  'has_nocache_code' => false,
)); /*/%%SmartyHeaderCode%%*/?>
<?php if (!is_callable('smarty_function_html_options')) include 'D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\sil1\include\Smarty\libs\plugins\function.html_options.php';
if (!is_callable('smarty_function_html_select_date')) include 'D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\sil1\include\Smarty\libs\plugins\function.html_select_date.php';
?><?php $_template = new Smarty_Internal_Template("header.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
  $(".delete").live('click', function(event) 
  {
    $(this).parent().remove();
  });
  $('#totVadhGhat').val("<?php echo $_smarty_tpl->getVariable('totVadhGhat')->value;?>
");
});

function addSetVadhGhat(txtObj)
{
	var row = $(txtObj).parents('.kaarigarRow');
	var dr = isNaN(parseFloat(row.find('.addDebit').val())) ? 0 : parseFloat(row.find('.addDebit').val());
	var cr = isNaN(parseFloat(row.find('.addCredit').val())) ? 0 : parseFloat(row.find('.addCredit').val());
  var price = cr - dr;
  isNaN(price) ? row.find('.addVadhaaroGhataado').val("") : row.find('.addVadhaaroGhataado').val(price);
  totalVadhGhat();
  setVadhGhat();
}

function setVadhGhat(txtObj)
{
	var row = $(txtObj).parents('.kaarigarRow');
	var cr = isNaN(parseFloat(row.find('.credit').val())) ? 0 : parseFloat(row.find('.credit').val());
	var dr = isNaN(parseFloat(row.find('.debit').val())) ? 0 : parseFloat(row.find('.debit').val());
  var price = cr - dr;
  isNaN(price) ? row.find('.vadhaaroGhataado').val("") : row.find('.vadhaaroGhataado').val(price);
  totalVadhGhat();
}

function totalVadhGhat()
{
	var totVadhGhat = 0;
	var totCrAmount = 0;
	var totDrAmount = 0;
  
  $('.vadhaaroGhataado').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totVadhGhat += Number(price);
  });
  $('#totVadhGhat').val(totVadhGhat);
  
  $('.crAmount').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totCrAmount += Number(price);
  });
  $('#totCrAmount').val(totCrAmount);
  
  $('.drAmount').each(function(i)
  {
    price = $(this).val().replace("$","");
    if (!isNaN(price)) totDrAmount += Number(price);
  });
  $('#totDrAmount').val(totDrAmount);
}

function setAmount(txtObj)
{
  var row = $(txtObj).parents('.kaarigarRow');
  var price = parseFloat(row.find('.qty').val()) * parseFloat(row.find('.rate').val());
  isNaN(price) ? row.find('.crAmount').val("") : row.find('.crAmount').val(price);
}

function addNewRow()
{
  $('#kaarigarTable tr:last').after('<tr class="kaarigarRow"><td><input type="text" name="particulars[]" class="particulars"\/><\/td><td><input type="text" name="debit[]" size="8" class="debit" onChange="setVadhGhat(this)" \/><\/td><td><input type="text" name="credit[]" size="8" class="credit" onChange="setVadhGhat(this)" \/><\/td><td><input type="text" name="particular[]" class="particular"\/><\/td><td><input type="text" name="vadhaaroGhataado[]" size="8" class="vadhaaroGhataado" onChange="totalVadhGhat()" \/><\/td><td><input type="text" name="addDebit[]" size="8" class="addDebit" onChange="addSetVadhGhat(this)" \/><\/td><td><input type="text" name="addCredit[]" size="8" class="addCredit" onChange="addSetVadhGhat(this)" \/><\/td><td><input type="hidden" name="addVadhaaroGhataado[]" size="8" class="addVadhaaroGhataado" onChange="addSetVadhGhat(this)" \/><\/td><td><input type="text" name="qty[]" size="8" class="qty" onChange="setAmount(this)" \/><\/td><td><input type="text" name="rate[]" size="8" class="rate" onChange="setAmount(this)" \/><\/td><td><input type="text" name="crAmount[]" size="8" class="crAmount" onChange="addSetVadhGhat()" \/></td><td><input type="text" name="drAmount[]"size="8" class="drAmount" onChange="addSetVadhGhat()" \/><\/td><td><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
<\/a><\/td><td class="delete"><?php echo $_smarty_tpl->getVariable('l_remove')->value;?>
<\/td><\/tr>');
}
</script>
<form name="form1" action="" method="post">
<input type="hidden" name="kaarigarMasterId" value="<?php echo $_smarty_tpl->getVariable('kaarigarMasterId')->value;?>
" />
<input type="hidden" name="bdate" id="bdate" value="0" />
<input type="hidden" name="isEdit" value="<?php echo $_smarty_tpl->getVariable('isEdit')->value;?>
" />
<center><h4><?php echo $_smarty_tpl->getVariable('l_kaarigarEntry')->value;?>
</h4></center>
<div class="contentDiv">
  <table border="0" id="kaarigarTable" align="center" width="100%">
  <tr>
    <td colspan="4" class="table1">
      <?php echo $_smarty_tpl->getVariable('l_kaarigarName')->value;?>
 :
      <select name="kaarigarId">
        <?php echo smarty_function_html_options(array('values'=>$_smarty_tpl->getVariable('kaarigar')->value['id'],'output'=>$_smarty_tpl->getVariable('kaarigar')->value['name'],'selected'=>$_smarty_tpl->getVariable('kaarigarDetail')->value[0]['kaarigarId']),$_smarty_tpl->smarty,$_smarty_tpl);?>

      </select>
    </td>
    <td  colspan="10" class="table1">
      <?php echo $_smarty_tpl->getVariable('l_date')->value;?>
 : 
      <?php echo smarty_function_html_select_date(array('prefix'=>"curDate",'start_year'=>"-2",'end_year'=>"+1",'field_order'=>"DMY",'day_value_format'=>"%02d",'time'=>$_smarty_tpl->getVariable('kaarigarDetail')->value[0]['kaarigarDate']),$_smarty_tpl->smarty,$_smarty_tpl);?>

    </td>
  </tr>
  <tr class="table1">
    <th>Parti</th>
    <th><?php echo $_smarty_tpl->getVariable('l_debit')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_credit')->value;?>
</th>
    <th>Parti</th>
    <th><?php echo $_smarty_tpl->getVariable('l_vadhaaroGhataado')->value;?>
</th>
    <th>Ad.J</th>
    <th>Ad.A</th>
    <th>&nbsp;</th>
    <th><?php echo $_smarty_tpl->getVariable('l_qty')->value;?>
</th>
    <th><?php echo $_smarty_tpl->getVariable('l_rate')->value;?>
</th>
    <th>Cr Amt</th>
    <th>Dr Amt</th>
    <th>&nbsp;</th>
    <th>&nbsp;</th>
  </tr>
  <?php unset($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['name'] = "sec";
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'] = is_array($_loop=count($_smarty_tpl->getVariable('kaarigarDetail')->value)) ? count($_loop) : max(0, (int)$_loop); unset($_loop);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show'] = true;
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['max'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'] = 1;
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['start'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'] > 0 ? 0 : $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop']-1;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show']) {
    $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['loop'];
    if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] == 0)
        $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show'] = false;
} else
    $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'] = 0;
if ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['show']):

            for ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['start'], $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] = 1;
                 $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] <= $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total'];
                 $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] += $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'], $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration']++):
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['rownum'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index_prev'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] - $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index_next'] = $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['index'] + $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['step'];
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['first']      = ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] == 1);
$_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['last']       = ($_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['iteration'] == $_smarty_tpl->tpl_vars['smarty']->value['section']["sec"]['total']);
?>
	  <tr class="kaarigarRow">
	    <td><input type="text" name="particulars[]" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['particulars'];?>
" /></td>
	    <td><input type="text" name="debit[]" size="8" class="debit" onChange="setVadhGhat(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['debit'];?>
" /></td>
	    <td><input type="text" name="credit[]" size="8" class="credit" onChange="setVadhGhat(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['credit'];?>
" /></td>
      <td><input type="text" name="particular[]" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['particular'];?>
" /></td>
	    <td><input type="text" name="vadhaaroGhataado[]" size="8" class="vadhaaroGhataado" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['vadhaaroGhatado'];?>
" /></td>
	    <td><input type="text" name="addDebit[]" size="8" class="addDebit" onChange="addSetVadhGhat(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['addDebit'];?>
" /></td>
	    <td><input type="text" name="addCredit[]" size="8" class="addCredit" onChange="addSetVadhGhat(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['addCredit'];?>
" /></td>
	    <td><input type="hidden" name="addVadhaaroGhataado[]" size="8" class="addVadhaaroGhataado" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['addVadhaaroGhataado'];?>
" /></td>
	    <td><input type="text" name="qty[]" size="8" class="qty" onChange="setAmount(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['qty'];?>
" /></td>
	    <td><input type="text" name="rate[]" size="8" class="rate" onChange="setAmount(this)" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['rate'];?>
" /></td>
	    <td><input type="text" name="crAmount[]" size="8" class="crAmount" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['crAmount'];?>
" /></td>
	    <td><input type="text" name="drAmount[]" size="8" class="drAmount" value="<?php echo $_smarty_tpl->getVariable('kaarigarDetail')->value[$_smarty_tpl->getVariable('smarty')->value['section']['sec']['index']]['drAmount'];?>
" /></td>
	    <td><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
</a></td>
	    <td class="delete"><?php echo $_smarty_tpl->getVariable('l_remove')->value;?>
</td>
	  </tr>
	<?php endfor; endif; ?>
	<tr class="kaarigarRow">
    <td><input type="text" name="particulars[]"/></td>
    <td><input type="text" name="debit[]"     size="8" class="debit" onChange="setVadhGhat(this)" /></td>
    <td><input type="text" name="credit[]"    size="8" class="credit" onChange="setVadhGhat(this)" /></td>
    <td><input type="text" name="particular[]" /></td>
    <td><input type="text" name="vadhaaroGhataado[]" size="8" class="vadhaaroGhataado" onChange="totalVadhGhat()" /></td>
    <td><input type="text" name="addDebit[]"  size="8" class="addDebit" onChange="addSetVadhGhat(this)" /></td>
    <td><input type="text" name="addCredit[]" size="8" class="addCredit" onChange="addSetVadhGhat(this)" /></td>
    <td><input type="hidden" name="addVadhaaroGhataado[]" size="8" class="addVadhaaroGhataado" onChange="setVadhGhat()" /></td>
    <td><input type="text" name="qty[]"       size="8" class="qty" onChange="setAmount(this)" /></td>
    <td><input type="text" name="rate[]"      size="8" class="rate" onChange="setAmount(this)" /></td>
    <td><input type="text" name="crAmount[]"  size="8" class="crAmount" onChange="addSetVadhGhat()" /></td>
    <td><input type="text" name="drAmount[]"  size="8" class="drAmount" onChange="addSetVadhGhat()"/></td>
    <td><a href="javascript:addNewRow();"><?php echo $_smarty_tpl->getVariable('l_add')->value;?>
</a></td>
    <td class="delete"><?php echo $_smarty_tpl->getVariable('l_remove')->value;?>
</td>
  </tr>
  </table>
  <table width="100%">
  	<tr class="itemRowTot">
	  	<td width="130px;">&nbsp;</td>
	  	<td width="130px;">&nbsp;</td>
	  	<td width="130px;"><?php echo $_smarty_tpl->getVariable('l_total')->value;?>
</td>
	  	<td><input type="text" name="totalVadhGhat" id="totVadhGhat" /></td>
	  	<td width="130px;">&nbsp;</td>
	  	<td width="130px;">&nbsp;</td>
	  	<td width="130px;">&nbsp;</td>
	  	<td><input type="text" name="totCrAmount" id="totCrAmount" /></td>
	  	<td><input type="text" name="totDrAmount" id="totDrAmount" /></td>
	  </tr>
  </table>
  <input type="submit" name="submitBtn" value="<?php if (count($_smarty_tpl->getVariable('kaarigarDetail')->value)>0){?> <?php echo $_smarty_tpl->getVariable('l_save')->value;?>
 <?php }else{ ?> <?php echo $_smarty_tpl->getVariable('l_add')->value;?>
 <?php }?>" />
</div>
</form>
<?php $_template = new Smarty_Internal_Template("footer.tpl", $_smarty_tpl->smarty, $_smarty_tpl, $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, null, null);
 echo $_template->getRenderedTemplate();?><?php $_template->updateParentVariables(0);?><?php unset($_template);?>